<?php
class Konsumen extends CI_Model {

	function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }

    function insert($data){
        $this->db->insert('konsumen',$data);
    }

    function update($id,$data){
        $this->db->where('id_konsumen', $id);
        $this->db->update('konsumen', $data);
    }

    function delete($data){
        $this->db->where('id_konsumen', $data);
        $this->db->delete('konsumen');
    }

    function get_by_id($id){
        $this->db->from('konsumen');
        $this->db->where('id_konsumen', $id);
        $query = $this->db->get();
        return $query->result_array();
    }

    function get_all(){
        $this->db->from('konsumen');
        $query = $this->db->get();
        return $query->result_array();
    }

    function get_list(){
        $this->db->select('nama');
        $this->db->from('konsumen');
        $query = $this->db->get();
        return $query->result_array();
    }

    function get_by_nama($nama){
        $this->db->select('id_konsumen');
        $this->db->from('konsumen');
        $this->db->where('nama',$nama);
        $query = $this->db->get();
        return $query;
    }

   
}
